package test1_1;

public class CommissionCalculator {

    public float commission(int headphones, int shells, int protectors) {
        float salary;   // 佣金
        float total;    // 总销售额
        if (headphones <=0 || shells < 0 || protectors < 0)   // 判断数量的合法性
            return -1;
        total = headphones * 80 + shells * 10 + protectors * 8;
        if (total < 1000)    // 计算佣金
            salary = total * 0.1f;
        else if (total < 1800)
            salary = 1000 * 0.1f + (total - 1000) * 0.15f;
        else
            salary = 1000 * 0.1f + 800 * 0.15f + (total - 1800) * 0.2f;
        return salary;
    }
}
